<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org" th:with="title=${blog.blogTitle},isLogin=${session.sessionUser==null?false:true},hasEditor=false"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<!-- head 头部-->
<head th:replace="web/common/fragment::head(${title},null,'')"></head>
	<body>

		<div th:replace="web/layout/header::header(${active})"></div>
		<!--	main	-->
		<div class="fly-main">
			<div class="layui-row layui-col-space20">
					<div class="post-detail clear" style="transform: none;">
						<div class="post-detail-right" style="position: relative; overflow: visible; box-sizing: border-box; min-height: 1px;">
							<!--归档-->
							<div th:replace="web/view/blog/template::classify-sidebar"></div>
							<!--分类-->
							<div th:replace="web/view/blog/template::archive-sidebar"></div>
						</div>
						<div class="post-detail-left">
							<div class="post-list-box words">
								<div class="post-user-info">
									<div class="post-user-info-avatar">
										<a th:href="'/user/'+${blog.author.id}" style="display: inline-block;">
											<img th:src="${thUtil.formatUserImage(blog.author.userImg)}"
												 class="avatar opacity"
												 width="40" height="40" th:alt="${blog.author.nickName}"/>
											<div th:include="web/common/template::verify(${blog.author.userGrade})"></div>
										</a>
									</div>
									<div class="post-user-info-name">
										<a th:href="'/user/'+${blog.author.id}" th:text="${blog.author.nickName}">unknown</a>
										<span th:if="${blog.author.isAdmin=true}" class="javabb-mark javabb-honor" style="background:#009688">管理员</span>
									</div>
									<div class="post-user-info-time" th:title="${#dates.format(blog.createTime, 'yyyy-MM-dd HH:mm:ss')}" th:text="${#dates.format(blog.createTime, 'yyyy-MM-dd HH:mm:ss')}">
										2019-10-27 16:45:15
										<span>电脑端</span>
									</div>
								</div>
								<h1 class="title">
									<th:block th:text="${blog.blogTitle}">博客标题</th:block>
									<span th:if="${blog.blogTop}" class="javabb-mark javabb-top">顶</span>
									<span th:if="${blog.blogSupport}" class="javabb-mark javabb-commend">荐</span>
								</h1>
								<!--内容-->
								<div class="post-detail-content" th:utext="${blog.content}">
									内容
								</div>
								<!--tag标签-->
								<div class="post-detail-tag-list clear">
									<a href="#" th:each="tag:${thUtil.toList(blog.blogTags)}">
										<div class="left">#</div>
										<span th:text="${tag}">Java</span>
									</a>
								</div>
								<!--附加信息-->
								<div class="post-bar">
									<div th:include="web/view/blog/template::post-count-info(${blog})"></div>
								</div>

								<div class="javabb-comment-form" style="display: block;">
									<th:block th:switch="${#configUtil.getConfigValue('gobalCommentState')}">
										<th:block th:case="'1'">
											<th:block th:if="${blog.commentState}">
												<div class="javabb-comment-no-power" th:if="${!isLogin}">
													<div class="javabb-tips">
														<p>  请登录之后再进行评论  </p>
														<div class="login-btn opacity" th:onclick="|showLoginForm()|">登陆</div>
													</div>
												</div>
												<div class="javabb-comment-box clear" th:if="${isLogin}">
													<textarea class="javabb-comment-textarea" style="height: 85px;"></textarea>
													<div class="javabb-comment-btn"
														 th:onclick="|javabb_comment_blog(${blog.blogId},this)|">回  复
													</div>
												</div>
											</th:block>
											<div class="javabb-comment-no-power" th:if="${!blog.commentState}">
												<div class="javabb-tips">
													<p>  文章没有开启评论功能  </p>
												</div>
											</div>
										</th:block>
										<th:block th:case="'0'">
											<div class="javabb-comment-no-power">
												<div class="javabb-tips">
													<p>  网站评论功能关闭  </p>
												</div>
											</div>
										</th:block>
									</th:block>

									<!--<div class="javabb-comment-box clear">
										<textarea class="javabb-comment-textarea" style="height: 85px;"></textarea>
										<div class="javabb-comment-btn">评论</div>
									</div>-->
									<div class="javabb-comment-list" th:if="${not #lists.isEmpty(comments)}">
										<li th:each="comment,iterStat:${comments}">
											<div class="javabb-comment-avatar">
												<a th:href="'/user/'+${comment.user.id}" >
													<img th:src="${thUtil.formatUserImage(comment.user.userImg)}"
														 class="avatar opacity" width="20" height="20" th:alt="${comment.user.nickName}">
													<div th:include="web/common/template::verify(${blog.author.userGrade})"></div>
												</a>
											</div>
											<div class="javabb-comment-header">
												<span class="javabb-comment-up">
													<i class="layui-icon ali-icon-praise"></i>
													<m>3</m>
												</span>
												<div class="javabb-comment-info">
													<a href="#" target="_blank" th:text="${comment.user.nickName}">unknow</a>
													<!--<span class="javabb-mark javabb-honor"></span>-->
												</div>
												<div class="javabb-comment-info-footer">
													<span class="javabb-comment-time" th:title="${#dates.format(comment.createTime, 'yyyy-MM-dd HH:mm:ss')}"
														  th:text="${thUtil.formatPublishDate(comment.createTime)}">2月前</span>
													<span class="javabb-comment-form">来自 电脑端</span>
												</div>
											</div>

											<div class="javabb-comment-content" title="2019-09-20 15:47:39" th:text="${comment.commentContent}">这里是评论内容</div>
											<div class="javabb-comment-footer">
												<span>删除</span>
												<span th:text="${iterStat.count}+'楼'">1楼</span>
											</div>
										</li>
									</div>
								</div>
							</div>

						</div>

					</div>
			</div>
		</div>
		<!--	contianer end	-->
<!--	底部版权		-->
<div th:replace="web/layout/footer::footer"></div>
<!--	搜索		-->
<div th:replace="web/layout/common::pop-search"></div>
<!--	右边工具栏	-->
<div th:replace="web/layout/common::right-bar"></div>
<!--	引入JS	-->
<div th:replace="web/common/fragment::js" ></div>
<script th:inline="javascript">
    layui.use('form', function(){
        var form = layui.form;
        var $ = layui.jquery;
        // 初始化是评论状态

        // 表单提交事件
        form.on('submit(publishSubmit)', function (data) {
        	//校验表单
        	checkForm(data);
            
            console.info(data.field);
            data.field.catalogId = catalogId;
            data.field.commentState = data.field.commentState==1?'1':'0';
            //data.field.parentId = data.field.parentId==null?'0':data.field.parentId;
            // 表单提交事件
            B.post({
                url: '/blog/publish/',
                loading: true,
                data: data.field,
                success: function (data) {
                    if (data.success) {
                        B.info(data.msg);
                        window.location.href="/blog/";
                    } else {
                        B.error(data.msg);
                    }
                }
            });
            
            return false;
        });
        function checkForm(content){
        	if(B.isEmpty(content)){
        		B.error("评论内容不能为空");
        		return;
        	}
        }
    })
</script>
	</body>
</html>
